import pandas as pd
import os
import shutil

# 读取Excel文件中的APK文件名
excel_path = r"F:\apk20250806\apk_file_list.xlsx"
source_dir = r"F:\apk20250806\vivoDownloads"
target_dir = r"F:\apk20250806\failUploads"

# 确保目标目录存在
os.makedirs(target_dir, exist_ok=True)

# 读取Excel文件
df = pd.read_excel(excel_path)

# 获取APK文件名列表
apk_files = df["APK文件名"].tolist()

# 复制文件
copied_count = 0
missing_files = []

for apk_file in apk_files:
    source_path = os.path.join(source_dir, apk_file)
    target_path = os.path.join(target_dir, apk_file)

    # 检查源文件是否存在
    if os.path.exists(source_path):
        # 复制文件
        shutil.copy2(source_path, target_path)
        copied_count += 1
        print(f"已复制: {apk_file}")
    else:
        missing_files.append(apk_file)
        print(f"文件不存在: {apk_file}")

# 输出结果统计
print(f"\n总共处理 {len(apk_files)} 个文件")
print(f"成功复制 {copied_count} 个文件")
print(f"未找到 {len(missing_files)} 个文件")

if missing_files:
    print("\n未找到的文件:")
    for file in missing_files:
        print(f"  - {file}")
